package shinesend.com.cn.valaanimtordemo;

import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

/**
 * Created by MyPC on 2016/11/9.
 *
 */
public class FrameActivity extends Activity {
    //播放动画的控件
    private ImageView frame_imageview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_frame);
        frame_imageview = (ImageView) findViewById(R.id.frame_imageview);
    }
    //开始动画;
    public void start(View view){
        //获得动画的Drawable资源
        AnimationDrawable drawable = (AnimationDrawable) frame_imageview.getDrawable();
        if (!drawable.isRunning()){
            drawable.start();
        }
    }
    //结束动画;
    public void stop(View view) {
        AnimationDrawable drawable = (AnimationDrawable) frame_imageview.getDrawable();
        if (drawable.isRunning()) {
            drawable.stop();
        }
    }

}
